<?php

namespace App\Http\Controllers;

use App\Models\User;
use Illuminate\Http\Request;

class UserController extends Controller
{
    public function show(User $user)
    {

        $user = $user->load(['repositories' => function ($q) {
            return $q->indexQuery()->limit(5);
        }, 'chapters' => function ($q) {
            return $q->indexQuery()->limit(5);
        }]);
        return view('resources.user.show')->with(compact('user'));
    }

    public function like(User $user,$id)
    {
        $user=$user->findOrFail($id);
        $user->toggleLikeBy();
    }
}
